package com.dkhseep.bigevent.controller;

import com.dkhseep.bigevent.pojo.Article;
import com.dkhseep.bigevent.pojo.PageBean;
import com.dkhseep.bigevent.pojo.Result;
import com.dkhseep.bigevent.service.ArticleService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 功能:
 * 作者:Dksheep
 * 日期:2024/10/1010:12
 */
@Validated
@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;
    @PostMapping()
    public Result addArticle(@RequestBody @Validated Article article) {
        articleService.addArticle(article);
        return Result.success();
    }
    @GetMapping()
    public Result<PageBean<Article>> getlist(
            @RequestParam Integer pageNum,
            @RequestParam Integer pageSize,
            @RequestParam(required = false) Integer categoryId,
            @RequestParam(required = false) String state
    ) {
        return Result.success(articleService.getlist(pageNum,pageSize,categoryId,state));
    }
}
